<template>
  <div>
    <van-nav-bar
      :border="false"
      title="精彩跟帖"
      left-text="返回"
      left-arrow
      @click-left="$router.back()"
    />
    <Maincomment
      v-for="item in commentList"
      :key="item.id"
      :commentData="item"
    />
    <WriteComment @reload="reloadComment" />
  </div>
</template>

<script>
export default {
  components: {
    Maincomment: () => import("../components/comment/mainComment"),
    WriteComment: () => import("../components/comment/writeComment"),
  },
  data() {
    return {
      commentList: [],
    };
  },
  created() {
    //发送请求获取评论列表
    this.$axios({
      url: "/post_comment/" + this.$route.query.id,
    }).then((res) => {
      this.commentList = res.data.data;
      console.log(this.commentList);
    });
  },
  methods: {
    reloadComment() {
      //发送请求获取评论列表
      this.$axios({
        url: "/post_comment/" + this.$route.query.id,
      }).then((res) => {
        this.commentList = res.data.data;
        console.log(this.commentList);
      });
    },
  },
};
</script>

<style>
</style>